#include <iostream>
#include <string.h>

using namespace std;

int n;
int ant[1000004];
int length;
double mini, maxi;
double tot;
double x;
int main()
{
    int time, i;
    double a, b, left , right;
    cin >> time;
    while (time-->0)
    {
        cin >> length >> n;
        for (i=1; i<=n; ++i)
             scanf("%d", ant+i);
       	left = right = ant[1];
       	
    //   	sort(ant+1, ant+n+1);
        for (i=2; i<=n; ++i)
        {
            if (left > ant[i] ) left = ant[i];
            if (right < ant[i] ) right = ant[i];
        }    

       	mini = 0;
       	for (i=1; i<=n; ++i)
       	{
       	    a = length - ant[i];
       	    b = a > ant[i] ? ant[i] : a;
       	    if (mini < b) mini = b;
       	}    

       	
       	tot = (right - left) /2;
       	a = left+tot;
       	b = length-a;
       	tot += a > b? a:b;
       	printf("%.0lf %.0lf\n", mini, tot);
     //  	cout << "min="<< mini << endl;
     //  	cout << "max="<< tot << endl;
       	
       	
    }    
    
    
    return 0;
}    


